import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Optional;
import javax.swing.*;

public class Demo {
    public static void main(String[] args) {
        JFrame jFrame = new JFrame("登录");
        jFrame.setLayout(new BorderLayout());

        JPanel jPanel = new JPanel();


//        jFrame.add(new JButton("北"), BorderLayout.NORTH);
//        jFrame.add(new JButton("南"), BorderLayout.SOUTH);
//        jFrame.add(new JButton("中"), BorderLayout.CENTER);



        JLabel a = new JLabel("用户名: ");
        JTextField b = new JTextField(20);
        JLabel c = new JLabel("密码: ");
        JPasswordField d = new JPasswordField(20);
        JButton e = new JButton("确认");


        jPanel.add(a);
        jPanel.add(b);
        jPanel.add(c);
        jPanel.add(d);
        jPanel.add(e);

        jFrame.add(jPanel);

        e.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JOptionPane.showMessageDialog(jFrame,"按钮被点击了");
            }
        });


        jFrame.setSize(300,300);
        jFrame.setDefaultCloseOperation(jFrame.EXIT_ON_CLOSE);//关闭时关闭程序
        jFrame.setVisible(true);

    }



}